package com.jack006.algorithmi.day1;

import java.util.Scanner;

/**
 * @Classname B1016
 * @Description 部分 A+B
 * @Date 2021-07-05 08:33
 * @Created by jack
 */
public class B1016 {


    public static Long getPA(String A, String DA) {
        StringBuilder stringBuilder = new StringBuilder();
        char[] chars = A.toCharArray();
        for (char aChar : chars) {
            if ((aChar+"").equalsIgnoreCase(DA)) {
                stringBuilder.append(aChar);
            }
        }
        String pa = stringBuilder.toString();
        if (pa.equals("")) {
            return 0L;
        }
        long value = Long.parseLong(pa);
        return value;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        String[] s = input.split(" ");
        Long pa = getPA(s[0], s[1]);
        Long pb = getPA(s[2],s[3]);
        System.out.println(pa + pb);

    }
}
